//
//  MainTabBarController.swift
//  RACDemo
//
//  Created by mark-work on 2018/4/17.
//  Copyright © 2018年 mark-work. All rights reserved.
//

import UIKit
let kClassKey = "rootVCClassString";
let kTitleKey = "title";
let kImgKey = "imageName";
let kSelImgKey = "selectedImageName";

class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setData()

    }
    func setData(){
        let array = [
            [kClassKey:"HomeViewController",
             kTitleKey : "首页",
             kImgKey : "我的",
             kSelImgKey:"img"
                ] as [String : Any],
            [kClassKey:"MyViewController",
             kTitleKey : "我的",
             kImgKey : "我的",
             kSelImgKey:"img"
                ] as [String : Any],
            ];
        
        for dic in array {
            let Clc =  NSClassFromString(dic[kClassKey] as! String ) as! UIViewController.Type
            let vc = Clc.init();
            
            let nav = UINavigationController(rootViewController: vc)
            let item = nav.tabBarItem;
            item?.title = dic[kTitleKey] as? String
            item?.image = UIImage(named: dic[kImgKey] as! String )?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
            item?.image = UIImage(named: dic[kSelImgKey] as! String)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)

            
            
//            item?.titleTextAttributes = {[NSForegroundColorAttributeName :UIColor.white()]}()
            
//            item?.titleTextAttributes(for: ([
//        kCTForegroundColorAttributeName: UIColor.whiteColor(),
//                ])()
            UITabBar.appearance().barTintColor=UIColor.black
            UITabBar.appearance().isTranslucent = true;
            self.addChildViewController(nav)

            
            
        }
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
